package com.jxufe.weather;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.log4j.Logger;

public class WeaMain {
	private static Logger logger = Logger.getLogger("myLog");
	public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
		System.out.println("test......");
		logger.info("log test......");
		Configuration conf = new Configuration();
	    Job job = Job.getInstance(conf, "weather statistic");
	    
	    job.setJarByClass(WeaMain.class);
	    
	    job.setMapperClass(WeaMapper.class);
	    job.setMapOutputKeyClass(Text.class);
	    job.setMapOutputValueClass(WeaBean.class);
	    
//	    job.setCombinerClass(WeaReducer.class);
	    
	    job.setReducerClass(WeaReducer.class);
	    
	    job.setPartitionerClass(WeaPartitioner.class);
	    job.setNumReduceTasks(4);
	    
	    job.setOutputKeyClass(Text.class);
	    job.setOutputValueClass(WeaStatBean.class);
	    
	    FileInputFormat.addInputPath(job, new Path(args[0]));
	    FileOutputFormat.setOutputPath(job, new Path(args[1]));
	    System.out.println("test end......");
	    System.exit(job.waitForCompletion(true) ? 0 : 1);
	    System.out.println("test......");
	}
}
